﻿using System;
using System.Globalization;
using System.Windows.Controls;
using System.Windows.Data;

namespace OpenLS.Spreadsheet.UI.Internals
{
    public class XamlElementContentAccessor: IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            XamlElement e = (XamlElement) values[0];
            ContentControl c = (ContentControl) values[1];
            IWorksheetFragment mode = (IWorksheetFragment)values[2];
            if (mode is WorksheetPage)
            {
                return e.GetContentFor(c);
            }
            return e.Content;
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }
}